GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-s -w" -tags=native -o html2pdf-linux-arm64/html2pdf main.go
tar zcvf html2pdf-linux-arm64.tar.gz html2pdf-linux-arm64/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -tags=native -o html2pdf-linux-amd64/html2pdf main.go
tar zcvf html2pdf-linux-amd64.tar.gz html2pdf-linux-arm64/
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -tags=native -o html2pdf-windows-amd64/html2pdf.exe main.go
zip -r html2pdf-windows-amd64.zip html2pdf-windows-amd64/

cat >Dockerfile.test <<'EOF'
ARG VERSION=v0.1.1

FROM dockerhub.qingcloud.com/lscool66/html2pdf:chromedp-arm64 AS arm64
RUN rm -rf ./html2pdf
COPY ./html2pdf-linux-arm64/html2pdf ./html2pdf
RUN chmod +x ./html2pdf
ENV PATCH_CWINLIS=true
ENV TZ=Asia/Shanghai
ENV LOG_LEVEL=DEBUG

FROM dockerhub.qingcloud.com/lscool66/html2pdf:chromedp AS amd64
RUN rm -rf ./html2pdf
COPY ./html2pdf-linux-amd64/html2pdf ./html2pdf
RUN chmod +x ./html2pdf
ENV PATCH_CWINLIS=true
ENV TZ=Asia/Shanghai
ENV LOG_LEVEL=DEBUG
EOF

cat >docker-compose.yml.test <<'EOF'
services:
  amd64:
    image: registry.us-west-1.aliyuncs.com/lscool66/html2pdf:chromedp-${VERSION}
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile.test
      args:
        VERSION: ${VERSION}
      target: amd64
      tags:
        - dockerhub.qingcloud.com/lscool66/html2pdf:chromedp-${VERSION}
        - sealos.hub:5000/lscool66/html2pdf:chromedp-${VERSION}
      platforms:
        - linux/amd64
      labels:
        description: html2pdf:chromedp
        version: ${VERSION}
        owner: lscool66
        create_by: lscool66
  arm64:
    image: registry.us-west-1.aliyuncs.com/lscool66/html2pdf:chromedp-${VERSION}-arm64
    platform: linux/arm64
    build:
      context: .
      dockerfile: Dockerfile.test
      args:
        VERSION: ${VERSION}
      target: arm64
      tags:
        - dockerhub.qingcloud.com/lscool66/html2pdf:chromedp-${VERSION}-arm64
        - sealos.hub:5000/lscool66/html2pdf:chromedp-${VERSION}-arm64
      platforms:
        - linux/arm64
      labels:
        description: html2pdf:chromedp-arm64
        version: ${VERSION}
        owner: lscool66
        create_by: lscool66
EOF

VERSION=v0.1.1 docker compose -f docker-compose.yml.test build
VERSION=v0.1.1 docker compose -f docker-compose.yml.test push
